/****************************************************
文件：DSingle.cs
作者：UnitySir
邮箱：zouajck@foxmail.com
日期：2021/03/22 20:24:37
功能：Nothing
*****************************************************/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace DSFramework
{
    public class DSingle<T> where T : new()
    {
        private static T instance;
        private static object obj = new object();

        public static T Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (obj)
                    {
                        if (instance == null)
                        {
                            lock (obj)
                            {
                                instance = new T();
                            }
                        }
                    }
                }

                return instance;
            }
        }
    }
}